#include <iostream>
#include <math.h>
using namespace std;

signed main()
{
    int n;
    cin>>n;
    int championID,rookieID;
    double mind = 100*100*2,maxd = -1;
    for(int i=0;i<n;i++){
        int id;
        double x,y;
        cin>>id>>x>>y;
        int t = sqrt(x*x+y*y);
        if(t>maxd){
            rookieID = id;
            maxd = t;
        }
        if(t<mind){
            championID = id;
            mind = t;
        }
    }
    printf("%04d %04d",championID,rookieID);
    return 0;
}
